﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Babelfish.Extensions
{
    /// <summary>
    /// 
    /// </summary>
    public static class IAttributeExtensions
    {
        /// <summary>
        /// Removes the specified attribute.
        /// </summary>
        /// <param name="attribute">The attribute.</param>
        /// <returns></returns>
        public static IAttribute Remove(this IAttribute attribute)
        {
            attribute.ParentCollection.Remove(attribute);
            return attribute;
        }

        /// <summary>
        /// Removes the specified attributes.
        /// </summary>
        /// <param name="attributes">The attributes.</param>
        /// <returns></returns>
        public static IEnumerable<IAttribute> Remove(this IEnumerable<IAttribute> attributes)
        {
            var l = attributes.ToList();
            foreach (var attribute in l)
                attribute.ParentCollection.Remove(attribute);

            return l;
        }
    }
}
